package com.example.mall.order.domain.vo;

import com.example.mall.common.handler.ArrayTypeHandler;
import com.example.mall.order.domain.service.Merch;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;

/**
 * 商品项
 *
 * @author Mickey
 * @since 2022/4/22
 **/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class MerchItem implements Merch {

    private String name;
    private Long merchId;
    private BigDecimal price;

    @Override
    public MerchItem desc() {
        return this;
    }

    @Component
    public static class MerchItemArrayType extends ArrayTypeHandler<MerchItem> {
        public MerchItemArrayType(ObjectMapper objectMapper) {
            super(objectMapper);
        }

        @Override
        public TypeReference<List<MerchItem>> getType() {
            return new TypeReference<List<MerchItem>>() {
            };
        }
    }
}
